//
//  StatusCell.swift
//  sinaWeibo
//
//  Created by liii on 16/7/24.
//  Copyright © 2016年 liii. All rights reserved.
//

import UIKit
import SnapKit

class StatusCell: UITableViewCell {
    
    var status: Status? {
        didSet {
            // 把数据传递给原创微博
            originalView.status = status
        }
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        // 搭建UI界面
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
    
        // 添加子控件
        contentView.addSubview(originalView)
        contentView.addSubview(bottomView)
        
        // 设置约束
        originalView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentView.snp_top)
            make.left.equalTo(contentView.snp_left)
            make.width.equalTo(contentView.snp_width)
        }
        
        bottomView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(originalView.snp_bottom)
            make.left.equalTo(originalView.snp_left)
            make.width.equalTo(originalView.snp_width)
            make.height.equalTo(35)
        }
        // 自动计算行高 No.3
        contentView.snp_makeConstraints { (make) -> Void in
            make.top.left.right.equalTo(self)
            make.bottom.equalTo(bottomView.snp_bottom)
        }
        
    }

    // 原创微博视图
    private lazy var originalView: StatusOriginalView = StatusOriginalView()
    // 微博底部视图
    private lazy var bottomView: StatusBottomView = StatusBottomView()
}
